package com.itheima.reggie.common;


/**
 * 基于ThreadLocal封装的工具类,用于保存和获取当前登录用户的id
 * 作用范围：一次线程之内
 */
public class BaseContext {

    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 将值存入threadLocal当中
     * @param id
     */
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * 获取threadLocal当中的值
     * @return
     */
    public static Long getCurrent(){
        return threadLocal.get();
    }
}
